<template>
	<view class="category">
		<view @tap="goGoodsList(item.id)" class="category-item" v-for="item in categoryList" :key="item.id">
			<image :src="item.icon" mode=""></image>
			<view > {{item.name}} </view>
		</view>
	</view>
</template>

<script>
	import {
		categorys
	} from '@/api/home/index.js'
	export default {
		name:"Category",
		data() {
			return {
				categoryList:[]
			};
		},
		onLoad(){
				this.getCategoryList()
				
		},
		onShow() {
			getApp().globalData.user.name = "李四"
			
		},
		methods:{
			async getCategoryList(){
				let res = await categorys('1308336521604599809')
				this.categoryList = res.data.category.children
			},
			goGoodsList(id){
				// console.log("aaa")
				uni.navigateTo({
					url:`/pages/kind/goodsList/goodsList?id=${id}`
				})
			}
		}
	}
</script>

<style lang="scss" scoped>

</style>
